﻿using System.Collections;
using System.Data;
using Com.Seezt.Skins;
using Components;
using UI.Lib;
using UI.Lib.Factory;
using UI.ParentForm;

namespace UI.Charts
{
    public partial class FrmPssSummaryQuery : BaseQuery
    {
        public FrmPssSummaryQuery(string modulecode, string action) :
            base(modulecode, action)
        {
            InitializeComponent();
        }

        public override bool BeforePopWin(string name, ref string where, ref string[] others)
        {
            if ("productcode" == name)
            {
                where = string.Format("status ='1' {0}", Context.GetAppKeyWhere("muser", true));
            }
            else if ("stocode" == name)
            {
                where = string.Format("statuscode = '1' {0}",
                         Context.GetAppKeyWhere("usercode", true));
            }

            return true;
        }

        protected override void DoSearch()
        {
            var startDate = Validation.ToDate(this.tbSummary.GetValue("startdate"), Global.MinDate); //控件ID
            var endDate = Validation.ToDate(this.tbSummary.GetValue("endate"), Global.MinDate); //结束日期ID

            //控制明细中列显示
            var where = new Hashtable();
            where["merch"] = Validation.ToString(this.tbSummary.GetValue("pid")); //控件ID
            where["muser"] = Context.Comocde + "%";
            where["tdate"] = startDate;
            where["edate"] = endDate.AddDays(1); //结束日期
            where["warehouse"] = Validation.ToString(this.tbSummary.GetValue("storageid"));

            DataTable dt = CommonHelper.Entity.ExecFun("getpsssummaryquery", where);

            BinderGrid(dt);
        }
    }
}
